<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 7/24/24
 * Time: 2:01 PM
 */


namespace app\common\model\media;


use app\common\model\auth\Admin;
use app\common\model\BaseModel;
use app\common\model\promotion\PromotionLink;
use app\common\model\team\Team;


class MediaAccount extends BaseModel
{

    protected $name = 'media_account';


    /**
     * @notes  获取分类名称
     * @param $value
     * @param $data
     * @return string
     * @author heshihu
     * @date 2022/2/22 9:53
     */
    public function getAdminNameAttr($value, $data)
    {
        return Admin::where('id', $data['admin_id'])->value('name');
    }

    /**
     * @notes  获取分类名称
     * @param $value
     * @param $data
     * @return string
     * @author heshihu
     * @date 2022/2/22 9:53
     */
    public function getTeamNameAttr($value, $data)
    {
        return Team::where('id', $data['team_id'])->value('name');
    }


    /**
     * 所属媒体
     *
     * @return \think\model\relation\HasOne
     */
    public function media()
    {
        return $this->hasOne(Media::class, 'id', 'media_id');
    }


    /**
     * 关联的推广链
     *
     * @return \think\model\relation\HasOne
     */
    public function link()
    {
        return $this->hasOne(PromotionLink::class, 'id', 'promotion_link_id');
    }


    public function auth()
    {
        return $this->hasOne(MediaAuth::class, 'id', 'media_auth_id');
    }
}
